<?php
namespace App\Http\Controllers\Admin;

use App\Model\UserModel;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class UserListController extends Controller
{

    function index(Request $request)
    {
      try{
            $userMaster = new UserModel();
            $userInfo = $userMaster->readUserMaster();
            return view('admin.userlist', array(
                'userInfos' => $userInfo
            ));
        }catch (\Exception $e){
            \Log::error($e->getFile()." Line:".$e->getLine()." Msg:".$e->getMessage());
        }
    }

    public function delUser(Request $request)
    {
       try{
            $user_id = $request->input('user_id');
            $userMaster = new UserModel();
            $flag = $userMaster->delUser($user_id);
            if ($flag) {
                return redirect('/admin/user')->with('success', '削除成功！');
            }
        }catch (\Exception $e){
            \Log::error($e->getFile()." Line:".$e->getLine()." Msg:".$e->getMessage());
        }
    }
}

